#!/bin/bash

set -e

if [[ -n "${RASTER_VISION_DEBUG}" ]]; then
    set -x
fi

function usage() {
    echo -n \
        "Usage: $(basename "$0")
Build library for integration or a release.
"
}

if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
    if [[ "${1:-}" == "--help" ]]; then
        usage
    else
        DOCKER_BUILDKIT=1 docker build \
            --build-arg BUILDKIT_INLINE_CACHE=1 \
            --build-arg BUILD_TYPE=fullbuild \
            --platform linux/amd64 \
            --build-arg CUDA_VERSION="12.1.1" \
            --build-arg UBUNTU_VERSION="22.04" \
            --cache-from=quay.io/azavea/raster-vision:pytorch-latest \
            -t "raster-vision-${IMAGE_TYPE}" \
            -f Dockerfile .
    fi
fi
